﻿{% extends "gma/base.html" %}
{% load static %}
{% load mytag %}

{% block extra_css %}
    <link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet">
    <link href="{% static 'css/inspinia.css' %}" rel="stylesheet">
    <link href="{% static 'css/inspinia_custom.css' %}" rel="stylesheet">
    <link href="{% static 'css/weui_custom.css' %}" rel="stylesheet">
{% endblock extra_css %}

<!-- CONTENT
  =====================================================================-->

{% block content %}

<div class="page__bd">

    <div class="-col-lg-4">
        <div class="-widget-head-color-box p-lg text-center {{ env.bg }}">
            <div class="m-b-md">
            <h2 class="font-bold no-margins">
            {% if is_banned %}
                <i class="fa fa-lock"></i> <s>{{ user.uid }}</s>
            {% else %}
                {{ user.uid }}
            {% endif %}
            </h2>
            </div>
            <a href="{% url 'gma:gallery' user.avatar|cdn %}">
                <img src="{{ user.avatar|cdn }}" class="rounded-circle circle-border m-b-md homepage-avatar" alt="avatar">
            </a>

        {% if is_authorised_caster %}
            <div>
                <span class="my-link"><a href="{% url 'gma:user_album' user.id %}"><i class="fa fa-images"></i> 照片 {{ user.images|length }}</a></span> |
                <span class="my-link"><a href="{% url 'gma:caster_video_list' user.id %}"><i class="fa fa-video"></i> 视频 {{ total_video_count }}</a></span> |
                <span class="my-link"><a href="{% url 'gma:caster_income_stat' user.id %}"><i class="fa fa-ticket-alt"></i> 收益 {{ total_income }}</a></span>
            </div>
        {% else %}
            <div>
                <span class="my-link"><a href="{% url 'gma:user_pay_detail' user.id %}"><i class="fa fa-gem"></i> 钻石 {{ user.diamond }}</a></span> |
                <span class="my-link"><a href="{% url 'gma:user_pay_detail' user.id %}"><i class="fa fa-money-bill-alt"></i> 充值 ￥{{ total_pay_money_amount }}</a></span>
            </div>
        {% endif %}

        </div>
        <div class="widget-text-box">
        {% if is_caster %}
            <h4 class="media-heading">{{ user.auth_nickname }}</h4>
            <p>{{ user.auth_signature }}</p>
        {% else %}
            <h4 class="media-heading">{{ user.nickname }}</h4>
            <p>{{ user.signature }}</p>
        {% endif %}
            <div class="text-center">
            {% if is_caster %}
                {% if user.status == 1 %}
                    <a class="btn btn-s btn-warning" href="javascript:MyGet('{% url 'gma:auth_agree' user.id %}', '{% url 'gma:authing_caster_list' %}')"><i class="fa fa-check"></i> 过审 </a>
                    <a class="btn btn-s btn-warning" href="javascript:MyGet('{% url 'gma:auth_reject' user.id %}', '{% url 'gma:authing_caster_list' %}')"><i class="fa fa-times"></i> 拒绝 </a>
                {% elif user.status == 2 %}
                    <a class="btn btn-s btn-danger" href="javascript:MyGet('{% url 'gma:auth_agree' user.id %}', '{% url 'gma:authing_caster_list' %}')"><i class="fa fa-check"></i> 过审 </a>
                {% elif user.status == 3 %}
                    <a class="btn btn-s btn-white" href="javascript:MyGet('{% url 'gma:auth_reject' user.id %}', '{% url 'gma:authing_caster_list' %}')"><i class="fa fa-times"></i> 撤审 </a>
                {% endif %}
            {% endif %}
                <br> <br>
            </div>

            <div class="text-center">
            {% if permissions.broadcaster_management.open %}
                <a class="btn btn-s btn-white" href="{% url 'gma:user_hx_message' user.id %}"><i class="fa fa-comment-dots"></i> 私信 </a>
            {% endif %}

            {% if permissions.add_diamond.open %}
            <a class="btn btn-s btn-white" href="javascript:;" id="showAddDiamondSheet"><i class="fa fa-gem"></i> 加钻 </a>
            {% endif %}

            {% if is_banned %}
                <a href="javascript:unbanUser()" class="btn btn-s btn-danger"><i class="fa fa-lock"></i> 解冻 </a>
            {% else %}
                <a href="javascript:banUser()" class="btn btn-s btn-white"><i class="fa fa-lock"></i> 冻结 </a>
            {% endif %}

            </div>
        </div>
    </div>

    <div class="weui-cells__title"><i class="fa fa-user"></i> 基本数据</div>
    <div class="weui-cells">
        <div class="weui-cell">
            <div class="weui-cell__bd"> 注册时间 </div>
            <div class="weui-cell__ft">{{ user.create_time|date:"Y-m-d H:i:s" }}</div>
        </div>

        {% if permissions.broadcaster_management.open %}
        <div class="weui-cell">
            <div class="weui-cell__bd"> 电话 </div>
            <div class="weui-cell__ft"><a href="tel:{{ user.mobile }}" style="color:#6A6A6A">{{ user.mobile }}</a></div>
        </div>
        {% endif %}

        <a class="weui-cell weui-cell_access" href="{% url 'gma:user_login_data' user.id %}">
            <div class="weui-cell__bd"> 设备 </div>
            <div class="weui-cell__ft">
            {{ user.last_login_version }}
            {% if is_ios_device %}
                <i class="fab fa-apple weui_grid_icon_fa_red"></i>
            {% else %}
                <i class="fab fa-android weui_grid_icon_fa"></i>
            {% endif %}
            </div>
        </a>

        {% if permissions.system_config.open %}
            <a class="weui-cell weui-cell_access" href="{% url 'gma:user_raw_data' user.id %}">
                <div class="weui-cell__bd"> Raw Data </div>
                <div class="weui-cell__ft"></div>
            </a>
        {% endif %}
    </div>

{% if is_caster %}
    <div class="weui-cells__title"> <i class="fa fa-video"></i> 房间设置</div>
    <div class="weui-cells">
{#        <a class="weui-cell weui-cell_access" href="{% url 'gma:caster_recommend_page' user.id %}">#}
{#            <div class="weui-cell__bd"> 推荐位 </div>#}
{#            <div class="weui-cell__ft"> {{ recommend_desp }} </div>#}
{#        </a>#}

        {% if permissions.broadcaster_management.open %}
        <div class="weui-cell weui-cell_access" id="showRoomTagsSheet">
            <div class="weui-cell__bd"> 房间品类 </div>
            <div class="weui-cell__ft">{{ user.tag_name }}</div>
        </div>
        {% else %}
        <div class="weui-cell weui-cell_access">
            <div class="weui-cell__bd"> 房间品类 </div>
            <div class="weui-cell__ft">{{ user.tag_name }}</div>
        </div>
        {% endif %}

        <div class="weui-cell">
            <div class="weui-cell__bd"> 开通房间推荐 </div>
            <div class="weui-cell__ft">
                <label for="switch_recommend_room" class="weui-switch-cp">
                    <input id="switch_recommend_room" class="weui-switch-cp__input" type="checkbox" {{ is_recommended }} onclick="clickRecommendRoomSwitch()" />
                    <div class="weui-switch-cp__box"></div>
                </label>
            </div>
        </div>

        {% if permissions.broadcaster_management.open %}
        <a class="weui-cell weui-cell_access" href="{% url 'gma:edit_room_heat_factor' user.id %}">
            <div class="weui-cell__bd"> 房间附加热度 </div>
            <div class="weui-cell__ft">+ {{ user.extra_heat }}</div>
        </a>
        {% endif %}
    </div>
{% endif %}

{% if is_caster %}
    <div class="weui-cells__title"> <i class="fa fa-user"></i>  资料审核</div>
    <div class="weui-cells">


        <a class="weui-cell weui-cell_access" href="{% url 'gma:user_personal_data' user.id %}">
            <div class="weui-cell__bd"> 真实姓名 </div>
            <div class="weui-cell__ft">{{ user.real_name }}</div>
        </a>

        <div class="weui-cell">
            <div class="weui-cell__bd"> 身份证号 </div>
            <div class="weui-cell__ft">{{ user.id_number }}</div>
        </div>

{#        <a class="weui-cell weui-cell_access" href="{% url 'gma:modify_caster_introduction' user.id %}">#}
{#            <div class="weui-cell__bd"> 自我介绍 </div>#}
{#            <div class="weui-cell__ft">{{ user.introduction }}</div>#}
{#        </a>#}

        <a class="weui-cell weui-cell_access" href="{% url 'gma:gallery' user.id_upside_image|cdn %}">
            <div class="weui-cell__bd"> 身份证正面照 </div>
            <div class="weui-cell__ft"><img src="{{ user.id_upside_image|cdn }}" class="right_large_avatar"></div>
        </a>

        <a class="weui-cell weui-cell_access" href="{% url 'gma:gallery' user.id_downside_image|cdn %}">
            <div class="weui-cell__bd"> 身份证反面照 </div>
            <div class="weui-cell__ft"><img src="{{ user.id_downside_image|cdn }}" class="right_large_avatar"></div>
        </a>

        <a class="weui-cell weui-cell_access" href="{% url 'gma:gallery' user.id_with_user_image|cdn %}">
            <div class="weui-cell__bd"> 手持身份证照 </div>
            <div class="weui-cell__ft"><img src="{{ user.id_with_user_image|cdn }}" class="right_large_avatar"></div>
        </a>

        <a class="weui-cell weui-cell_access" href="{% url 'gma:user_album' user.id %}">
            <div class="weui-cell__bd"> 相册 </div>
{#            {% if user.images|length > 0 %}#}
{#            <div class="weui-cell__bd">#}
{#                相册({{ user.images|length }})#}
{#                {% if auth_photo %}#}
{#                    <span class="weui-badge" style="margin-left: 5px;">!</span>#}
{#                {% endif %}#}
{#            </div>#}
{#            {% else %}#}
{#            <div class="weui-cell__bd">#}
{#                相册#}
{#                {% if auth_photo %}#}
{#                    <span class="weui-badge" style="margin-left: 5px;">!</span>#}
{#                {% endif %}#}
{#            </div>#}
{#            {% endif %}#}

            <div class="weui-cell__ft">
                <ul class="weui-uploader__files">
                    {% for image in sample_images %}
                    <li class="right_large_avatars" style="background-image:url({{ image|cdn }})"></li>
                    {% endfor %}
                </ul>
            </div>
        </a>

        <a class="weui-cell weui-cell_access" href="{% url 'gma:modify_caster_nickname' user.id %}">
            <div class="weui-cell__bd"> 昵称 </div>
            <div class="weui-cell__ft">{{ user.auth_nickname }}</div>
        </a>

        <a class="weui-cell weui-cell_access" href="{% url 'gma:modify_caster_signature' user.id %}">
            <div class="weui-cell__bd"> 签名 </div>
            <div class="weui-cell__ft">{{ user.auth_signature }}</div>
        </a>
    </div>
{% endif %}

    <div class="weui-cells__title"> <i class="fa fa-gem"></i> 钻石数据</div>
        <div class="weui-cells">
        <div class="weui-cell">
            <div class="weui-cell__bd"> 剩余钻石 </div>
            <div class="weui-cell__ft"> {{ user.diamond }} <i class="fa fa-gem"></i> </div>
        </div>

        {% if total_diamond_pay_amount > 0 %}
            <a class="weui-cell weui-cell_access" href="{% url 'gma:user_pay_detail' user.id %}">
                <div class="weui-cell__bd"> 充值钻石 </div>
                <div class="weui-cell__ft"> {{ total_diamond_pay_amount }} <i class="fa fa-gem"></i> </div>
            </a>
        {% else %}
            <div class="weui-cell weui-cell_access">
                <div class="weui-cell__bd"> 充值钻石 </div>
                <div class="weui-cell__ft"> {{ total_diamond_pay_amount }} <i class="fa fa-gem"></i> </div>
            </div>
        {% endif %}

        {% if total_diamond_input_amount > 0 %}
        <a class="weui-cell weui-cell_access" href="{% url 'gma:user_diamond_input_detail' user.id %}">
            <div class="weui-cell__bd"> 获得钻石 </div>
            <div class="weui-cell__ft"> {{ total_diamond_input_amount }} <i class="fa fa-gem"></i> </div>
        </a>
        {% endif %}

        {% if total_diamond_output_amount < 0 %}
        <a class="weui-cell weui-cell_access" href="{% url 'gma:user_diamond_output_detail' user.id %}">
            <div class="weui-cell__bd"> 消耗钻石 </div>
            <div class="weui-cell__ft"> {{ total_diamond_output_amount }} <i class="fa fa-gem"></i> </div>
        </a>
        {% endif %}
    </div>

    {% if guild %}
    <div class="weui-cells__title"> <i class="fa fa-landmark"></i> 公会 </div>
    <div class="weui-cells">
        <div class="weui-cell">
            <div class="weui-cell__bd"> 所属公会 </div>
            <div class="weui-cell__ft"> {{ guild.name }} </div>
        </div>

        {% if permissions.guild_management.open %}
        <a class="weui-cell weui-cell_access" href="javascript:leaveGuild()">
            <div class="weui-cell__bd"> <i class="fa fa-door-open green_color"></i> 请离公会 </div>
            <div class="weui-cell__ft"></div>
        </a>
        {% endif %}
    </div>
    {% endif %}

    {% if permissions.view_private_message.open %}
    <div class="weui-cells__title"> <i class="fa fa-comment-dots"></i> 私信记录 </div>
    <div class="weui-cells">
        <a class="weui-cell weui-cell_access" href="{% url 'gma:private_message_list' user.id %}">
            <div class="weui-cell__bd"> 私信 </div>
            <div class="weui-cell__ft"></div>
        </a>
    </div>
    {% endif %}

    <div class="weui-cells__title"> <i class="fa fa-paw"></i> 其他操作 </div>
    <div class="weui-cells">
        {% if permissions.broadcaster_management.open %}
            {% if is_banned_device %}
                <a class="weui-cell weui-cell_access" href="javascript:unbanUserDevice()">
                    <div class="weui-cell__bd"> <i class="fa fa-lock-open red_color"></i> 撤销设备冻结 </div>
                    <div class="weui-cell__ft"></div>
                </a>
            {% else %}
                <a class="weui-cell weui-cell_access" href="javascript:banUserDevice()">
                    <div class="weui-cell__bd"> <i class="fa fa-user-lock green_color"></i> 冻结设备 </div>
                    <div class="weui-cell__ft"></div>
                </a>
            {% endif %}

            {% if is_banned_ip %}
                <a class="weui-cell weui-cell_access" href="javascript:unbanUserIp()">
                    <div class="weui-cell__bd"> <i class="fa fa-lock-open red_color"></i> 撤销IP冻结 </div>
                    <div class="weui-cell__ft"></div>
                </a>
            {% else %}
                <a class="weui-cell weui-cell_access" href="javascript:banUserIp()">
                    <div class="weui-cell__bd"> <i class="fa fa-user-lock green_color"></i> 冻结IP </div>
                    <div class="weui-cell__ft"></div>
                </a>
            {% endif %}
        {% endif %}

        {% if permissions.system_config.open %}
            <a class="weui-cell weui-cell_access" href="javascript:refreshUserCache()">
                <div class="weui-cell__bd"> <i class="fa fa-sync-alt green_color"></i> 刷新缓存 </div>
                <div class="weui-cell__ft"></div>
            </a>

            <a class="weui-cell weui-cell_access" href="{% url 'gma:edit_radio_message' 0 user.id %}">
                <div class="weui-cell__bd"> <i class="fa fa-paper-plane green_color"></i> 推送消息 </div>
                <div class="weui-cell__ft"></div>
            </a>
        {% endif %}
    </div>
</div>

{% if permissions.broadcaster_management.open %}
    <div class="weui-mask" id="starMask" style="display: none"></div>
    <div class="weui-actionsheet" id="roomTagsActionsheet">
        <div class="weui-actionsheet__title">
            <p class="weui-actionsheet__title-text">设置房间品类</p>
        </div>
        <div class="weui-actionsheet__menu">
            {% for tag in room_tags %}
            <div class="weui-actionsheet__cell" onclick="javascript:set_room_tag({{ tag.tag_id }})"> {{ tag.tag_name }} </div>
            {% endfor %}
        </div>
        <div class="weui-actionsheet__action">
            <div class="weui-actionsheet__cell" id="starActionsheetCancel">取消</div>
        </div>
    </div>
{% endif %}

{% if permissions.add_diamond.open %}
<div class="weui-mask" id="addDiamondMask" style="display: none"></div>
<div class="weui-actionsheet" id="addDiamondActionsheet">
    <div class="weui-actionsheet__title">
        <p class="weui-actionsheet__title-text">给用户增加钻石</p>
    </div>
    <div class="weui-actionsheet__menu">
        <div class="weui-actionsheet__cell" onclick="javascript:add_diamond(1)">增加 <b>1</b> 钻石</div>
        <div class="weui-actionsheet__cell" onclick="javascript:add_diamond(100)">增加 <b>100</b> 钻石</div>
        <div class="weui-actionsheet__cell" onclick="javascript:add_diamond(420)">增加 <b>420</b> 钻石</div>
        <div class="weui-actionsheet__cell" onclick="javascript:add_diamond(600)">增加 <b>600</b> 钻石</div>
        <div class="weui-actionsheet__cell" onclick="javascript:add_diamond(2100)">增加 <b>2100</b> 钻石</div>
        <div class="weui-actionsheet__cell" onclick="javascript:add_diamond(3000)">增加 <b>3000</b> 钻石</div>
        <div class="weui-actionsheet__cell" onclick="javascript:add_diamond(6800)">增加 <b>6800</b> 钻石</div>
        <div class="weui-actionsheet__cell" onclick="javascript:add_diamond(12800)">增加 <b>12800</b> 钻石</div>
        <div class="weui-actionsheet__cell" onclick="javascript:add_diamond(29800)">增加 <b>29800</b> 钻石</div>
        <div class="weui-actionsheet__cell" onclick="javascript:add_diamond(40000)">增加 <b>40000</b> 钻石</div>
        <div class="weui-actionsheet__cell" onclick="javascript:add_diamond(100000)">增加 <b>100000</b> 钻石</div>
        <div class="weui-actionsheet__cell" onclick="javascript:add_diamond(300000)">增加 <b>300000</b> 钻石</div>

{#        <div class="weui-actionsheet__cell" onclick="javascript:add_diamond(100)">增加 <b>100</b> 钻石</div>#}
{#        <div class="weui-actionsheet__cell" onclick="javascript:add_diamond(1000)">增加 <b>1000</b> 钻石</div>#}
{#        <div class="weui-actionsheet__cell" onclick="javascript:add_diamond(10000)">增加 <b>10000</b> 钻石</div>#}
{#        <div class="weui-actionsheet__cell" onclick="javascript:add_diamond(20000)">增加 <b>20000</b> 钻石</div>#}
{#        <div class="weui-actionsheet__cell" onclick="javascript:add_diamond(50000)">增加 <b>50000</b> 钻石</div>#}
{#        <div class="weui-actionsheet__cell" onclick="javascript:add_diamond(1900000)">增加 <b>1900000</b> 钻石</div>#}
{#        <div class="weui-actionsheet__cell" onclick="javascript:add_diamond(9900000)">增加 <b>9900000</b> 钻石</div>#}
    </div>
    <div class="weui-actionsheet__action">
        <div class="weui-actionsheet__cell" id="addDiamondSheetCancel">取消</div>
    </div>
</div>
{% endif %}

<div class="page__ft">
    <a href="{% url 'gma:home' %}">
        <span class="bottom-logo">
           HiBao
       </span>
    </a>
</div>


{% endblock content %}

<!-- SCRIPT
  =====================================================================-->

{% block extra_js %}

<script type="text/javascript" class="actionsheet js_show">
$(function(){
    let $addDiamondActionsheet = $('#addDiamondActionsheet');
    let $addDiamondMask = $('#addDiamondMask');

    function hideActionSheet() {
        $addDiamondActionsheet.removeClass('weui-actionsheet_toggle');
        $addDiamondMask.fadeOut(200);
    }

    $addDiamondMask.on('click', hideActionSheet);
    $('#addDiamondSheetCancel').on('click', hideActionSheet);
    $("#showAddDiamondSheet").on("click", function(){
        $addDiamondActionsheet.addClass('weui-actionsheet_toggle');
        $addDiamondMask.fadeIn(200);
    });
});
</script>

<script>
function add_diamond(amount) {
    show_confirm_dialog('增加钻石', `你确定要给"{{ user.nickname }}({{ user.uid }})"增加 ${amount} 钻石给用户吗?`, ()=> {
        let url = "{% url 'gma:api_add_diamond' %}";
        let data = {
            'uid': {{ user.id }},
            'amount': amount,
        };

        new my_ajax(url, data, '', '', () => {
            show_toast(`为用户增加了${amount}钻石!`);
            setTimeout(() => {
                window.location.reload();
            }, 1000);
        });
    });
}

// 点击推荐按钮
function clickRecommendRoomSwitch() {
    let url = "{% url 'gma:api_recommend_room' %}";

    if ($('#switch_recommend_room').is(':checked')) {
        let data = {
            'uid': {{ user.id }},
            'allowed': 1,
        };

        new my_ajax(url, data, '', '', () => {
            show_toast(`推荐成功!`);

        });
    } else {
        let data = {
            'uid': {{ user.id }},
            'allowed': 0,
        };

        new my_ajax(url, data, '', '', () => {
            show_toast(`关闭推荐!`);

        });
    }
}

function leaveGuild() {
    show_confirm_dialog('请离公会成功', '你确定要将"用户-{{ user.id }}"请离公会吗?', ()=> {
        let url = "{% url 'gma:api_leave_guild' %}";
        let data = {
            'uid': {{ user.id }},
        };

        new my_ajax(url, data, '', '', () => {
            show_toast(`请离公会成功!`);
            setTimeout(() => {
                window.location.reload();
            }, 1000);
        });
    });
}

function banUser() {
    show_confirm_dialog('冻结账号', '你确定要冻结"用户-{{ user.id }}"的登录账号吗?', ()=> {
        let url = "{% url 'gma:api_ban_user' %}";
        let data = {
            'uid': {{ user.id }},
        };

        new my_ajax(url, data, '', '', () => {
            show_toast(`冻结账号!`);
            setTimeout(() => {
                window.location.reload();
            }, 1000);
        });
    });
}

function unbanUser() {
    show_confirm_dialog('撤销冻结账号', '你确定要撤销冻结"用户-{{ user.id }}"的登录账号吗?', ()=> {
        let url = "{% url 'gma:api_unban_user' %}";
        let data = {
            'uid': {{ user.id }},
        };

        new my_ajax(url, data, '', '', () => {
            show_toast(`撤销冻结账号!`);
            setTimeout(() => {
                window.location.reload();
            }, 1000);
        });
    });
}

function banUserDevice() {
    show_confirm_dialog('冻结设备', '你确定要冻结"用户-{{ user.id }}"的登录设备吗?', ()=> {
        let url = "{% url 'gma:api_ban_user_device' %}";
        let data = {
            'uid': {{ user.id }},
        };

        new my_ajax(url, data, '', '', () => {
            show_toast(`冻结设备!`);
            setTimeout(() => {
                window.location.reload();
            }, 1000);
        });
    });
}

function unbanUserDevice() {
    show_confirm_dialog('撤销冻结设备', '你确定要撤销冻结"用户-{{ user.id }}"的登录设备吗?', ()=> {
        let url = "{% url 'gma:api_unban_user_device' %}";
        let data = {
            'uid': {{ user.id }},
        };

        new my_ajax(url, data, '', '', () => {
            show_toast(`撤销冻结设备!`);
            setTimeout(() => {
                window.location.reload();
            }, 1000);
        });
    });
}

function banUserIp() {
    show_confirm_dialog('冻结IP', '你确定要冻结"用户-{{ user.id }}"的登录IP吗?', ()=> {
        let url = "{% url 'gma:api_ban_user_ip' %}";
        let data = {
            'uid': {{ user.id }},
        };

        new my_ajax(url, data, '', '', () => {
            show_toast(`冻结IP!`);
            setTimeout(() => {
                window.location.reload();
            }, 1000);
        });
    });
}

function unbanUserIp() {
    show_confirm_dialog('撤销冻结IP', '你确定要撤销冻结"用户-{{ user.id }}"的登录IP吗?', ()=> {
        let url = "{% url 'gma:api_unban_user_ip' %}";
        let data = {
            'uid': {{ user.id }},
        };

        new my_ajax(url, data, '', '', () => {
            show_toast(`撤销冻结IP!`);
            setTimeout(() => {
                window.location.reload();
            }, 1000);
        });
    });
}

function refreshUserCache() {
    let url = "{% url 'gma:api_refresh_user_cache' %}";
    let data = {
        'uid': {{ user.id }},
    };

    new my_ajax(url, data, '', '', () => {
        show_toast(`刷新用户缓存!`);
        setTimeout(() => {
            window.location.reload();
        }, 1000);
    });
}
</script>

{% if permissions.broadcaster_management.open %}
<script type="text/javascript" class="actionsheet js_show">
$(function(){
    let $roomTagsActionsheet = $('#roomTagsActionsheet');
    let $mask = $('#starMask');

    function hideActionSheet() {
        $roomTagsActionsheet.removeClass('weui-actionsheet_toggle');
        $mask.fadeOut(200);
    }

    $mask.on('click', hideActionSheet);
    $('#starActionsheetCancel').on('click', hideActionSheet);
    $("#showRoomTagsSheet").on("click", function(){
        $roomTagsActionsheet.addClass('weui-actionsheet_toggle');
        $mask.fadeIn(200);
    });
});

function set_room_tag(tag_id) {
    let url = "{% url 'gma:api_set_room_tag' %}";
    let data = {
        'uid': {{ user.id }},
        'tag_id': tag_id,
    };

    new my_ajax(url, data, '', '', () => {
        show_toast(`房间品类设置成功！`);
        setTimeout(() => {
            window.location.reload();
        }, 1000);
    });
}
</script>
{% endif %}

{% endblock extra_js %}